home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2004 #2 / K-CD-2-2004.ISO / OpenOffice Sv / f_0397 / python-core-2.2.2 / lib / test / test_dospath.py < prev    next >
Encoding:
Python Source  |  2003-07-18  |  2.1 KB  |  62 lines

  1. import dospath
  2. import test_support
  3. import unittest
  4.  
  5.  
  6. class DOSPathTestCase(unittest.TestCase):
  7.  
  8.     def test_abspath(self):
  9.         self.assert_(dospath.abspath("C:\\") == "C:\\")
  10.  
  11.     def test_isabs(self):
  12.         isabs = dospath.isabs
  13.         self.assert_(isabs("c:\\"))
  14.         self.assert_(isabs("\\\\conky\\mountpoint\\"))
  15.         self.assert_(isabs("\\foo"))
  16.         self.assert_(isabs("\\foo\\bar"))
  17.         self.failIf(isabs("foo"))
  18.         self.failIf(isabs("foo\\"))
  19.         self.failIf(isabs("foo\\bar"))
  20.         self.failIf(isabs("c:foo"))
  21.         self.failIf(isabs("c:foo\\"))
  22.         self.failIf(isabs("c:foo\\bar"))
  23.  
  24.     def test_commonprefix(self):
  25.         commonprefix = dospath.commonprefix
  26.         self.assert_(commonprefix(["/home/swenson/spam", "/home/swen/spam"])
  27.                      == "/home/swen")
  28.         self.assert_(commonprefix(["\\home\\swen\\spam", "\\home\\swen\\eggs"])
  29.                      == "\\home\\swen\\")
  30.         self.assert_(commonprefix(["/home/swen/spam", "/home/swen/spam"])
  31.                      == "/home/swen/spam")
  32.  
  33.     def test_split(self):
  34.         split = dospath.split
  35.         self.assertEquals(split("c:\\foo\\bar"),
  36.                           ('c:\\foo', 'bar'))
  37.         self.assertEquals(split("\\\\conky\\mountpoint\\foo\\bar"),
  38.                           ('\\\\conky\\mountpoint\\foo', 'bar'))
  39.  
  40.         self.assertEquals(split("c:\\"), ('c:\\', ''))
  41.         self.assertEquals(split("\\\\conky\\mountpoint\\"),
  42.                           ('\\\\conky\\mountpoint', ''))
  43.  
  44.         self.assertEquals(split("c:/"), ('c:/', ''))
  45.         self.assertEquals(split("//conky/mountpoint/"),
  46.                           ('//conky/mountpoint', ''))
  47.  
  48.     def test_splitdrive(self):
  49.         splitdrive = dospath.splitdrive
  50.         self.assertEquals(splitdrive("c:\\foo\\bar"), ('c:', '\\foo\\bar'))
  51.         self.assertEquals(splitdrive("c:/foo/bar"), ('c:', '/foo/bar'))
  52.         self.assertEquals(splitdrive("foo\\bar"), ('', 'foo\\bar'))
  53.         self.assertEquals(splitdrive("c:"), ('c:', ''))
  54.  
  55.  
  56. def test_main():
  57.     test_support.run_unittest(DOSPathTestCase)
  58.  
  59.  
  60. if __name__ == "__main__":
  61.     test_main()
  62.